/**
 * @Author: lusx
 * @Date:   07-03-2019 11:23:07
 * @Project: Govern督办
 * @Last modified by:   lusx
 * @Last modified time: 07-03-2019 11:31:51
 */
import React from "react";
import { observable, action } from "mobx";
import { Toast, Tools } from "weaver-mobile";
import * as Apis from "../../apis/govern";
const getLabel = Tools.getLabel;
//关注
class HeartStore {
  /**
   * 我的关注
   * @param {参数类型} {"id":"","heart":""} 参数说明  列表每行id;
   * @return {返回值类型}
   */
  @action
  setHeart(params) {
    if (params.heart === "0") {
      //取消关注
      Apis.disAttentTask({ id: params.id }).then(data => {
        if (data.status === "1") {
          Toast.hide();
          Toast.success(getLabel("385762", "已取消关注"));
        } else {
          Toast.hide();
          Toast.info(data.error);
        }
      });
    } else if (params.heart === "1") {
      //关注
      Apis.attentTask({ id: params.id }).then(data => {
        if (data.status === "1") {
          Toast.hide();
          Toast.success(getLabel("25436,84565", "关注成功"));
        } else {
          Toast.hide();
          Toast.info(data.error);
        }
      });
    }
  }
}
export default new HeartStore();
